// Copyright (c) 2007 Alistair Jones
// This program is made available under the terms of the MIT License.
package org.hypirinha.html.codegen;

import javax.xml.namespace.NamespaceContext;
import java.util.Iterator;
import java.util.Map;
import java.util.HashMap;

class XmlSchemaNamespaceContext implements NamespaceContext {

    private Map<String, String> prefixToUri = new HashMap<String, String>();

    {
        prefixToUri.put("xs", "http://www.w3.org/2001/XMLSchema");
    }

    public String getNamespaceURI(String prefix) {
        return prefixToUri.get(prefix);
    }

    public String getPrefix(String uri) {
        for (String prefix : prefixToUri.keySet()) {
            if (prefixToUri.get(prefix).equals(uri)) {
                return prefix;
            }
        }
        return null;
    }

    public Iterator getPrefixes(String s) {
        return prefixToUri.keySet().iterator();
    }
}
